/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.audit.aop  
 */
package com.apache.auditRule.server;

import java.lang.reflect.Method;

import org.apache.log4j.Logger;
import org.springframework.aop.AfterReturningAdvice;

import com.apache.api.entity.BaseEntity;
import com.apache.api.vo.ParamsVo;
import com.apache.cache.util.Validator;

public class AuditMethodAfterAdvice implements AfterReturningAdvice {

	private Logger log = Logger.getLogger(AuditMethodAfterAdvice.class);

	/**
	 * 拦截对memberManager的操作。 
	 */
	@SuppressWarnings("rawtypes")
	public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
		//String targetName = target.getClass().getName();
//		String methodName = method.getName();
//		ParamsVo arguments = (ParamsVo) args[0];
//		ParamsVo paramsVo = new ParamsVo<BaseEntity>();
//		String flag = (String) arguments.getParams("flag");
//
//		if ("editMemberAndSaveMemberRole".equals(methodName) && Validator.isNotNull(flag) && "T".equals(flag)) {
//			paramsVo.setParams("tableName", "t_member_role");
//			paramsVo.setParams("auditType", (String) arguments.getParams("auditType"));//addExpert
//			paramsVo.setParams("colName", "role_id");
//			paramsVo.setParams("pid", arguments.getParams("pid"));
//			paramsVo.setParams("userEname", arguments.getParams("userEname"));
//			AuditSaveHelper.newIntance().auditSave(paramsVo);
//		}
//		//增加一个会员并且增加一个会员角色时，审的是memberRole而非member。
//		if ("saveMemberAndRoles".equals(methodName) && Validator.isNotNull(flag) && "T".equals(flag)) {
//			paramsVo.setParams("tableName", "t_member_role");
//			paramsVo.setParams("auditType", (String) arguments.getParams("auditType"));//addMemberAndRoles
//			paramsVo.setParams("colName", "role_id");
//			paramsVo.setParams("pid", arguments.getParams("roleId"));
//			paramsVo.setParams("userEname", arguments.getParams("userEname"));
//			AuditSaveHelper.newIntance().auditSave(paramsVo);
//		}
		//当已经插入了member，但是需要再次修改roles时。auditType=editMemberAndRoles
	}
}
